package controller;

import model.Order;
import model.OrderGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import service.IOrderGoodsService;
import service.IOrderService;

import java.util.List;

/**
 * @aythor:侯仪澳
 * @data:2022/7/29
 */
@Controller
@RequestMapping("orderGoods")
public class OrderGoodsController {

    @Autowired
    private IOrderGoodsService orderGoodsService;
    @Autowired
    private IOrderService orderService;

    //查询订单号的所有信息
    @RequestMapping("queryOrderGoods")
    public ModelAndView queryOrderGoods(OrderGoods orderGoods){
        ModelAndView modelAndView = new ModelAndView();
        List<OrderGoods> list = orderGoodsService.queryOrderGoods(orderGoods);
        modelAndView.addObject("list", list);
        Order order = new Order(orderGoods.getOrderNo());
        List<Order> orders = orderService.queryAllOrder(order);
        modelAndView.addObject("order", orders);
        modelAndView.setViewName("manager/order_goods");
        return modelAndView;
    }
}
